{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "997231fc",
   "metadata": {},
   "source": [
    "* 日期：2022.11.16\n",
    "* 记录人：liyuanyuan"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "be2b3ce6",
   "metadata": {},
   "source": [
    "## P61"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "e171c666",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "provide a word to search for first: milliways\n",
      "i\n",
      "a\n"
     ]
    }
   ],
   "source": [
    "first = [\"a\", \"e\", \"i\",\"o\",\"u\"]\n",
    "second = input(\"provide a word to search for first: \")\n",
    "found = []\n",
    "for i in second:\n",
    "    if i in first:\n",
    "        if i not in found:\n",
    "            found.append(i)\n",
    "for first in found:\n",
    "    print(first)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1904c285",
   "metadata": {},
   "source": [
    "## p68"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "34aedc0b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Don't panic!\n",
      "['D', 'o', 'n', \"'\", 't', ' ', 'p', 'a', 'n', 'i', 'c', '!']\n",
      "['o', 'n', ' ', 't', 'a', 'p']\n",
      "on tap\n"
     ]
    }
   ],
   "source": [
    "phrase = \"Don't panic!\"\n",
    "plist = list(phrase)\n",
    "print(phrase)\n",
    "print(plist)\n",
    "for i in range(4):\n",
    "    plist.pop()\n",
    "plist.pop(0)\n",
    "plist.remove(\"'\")\n",
    "plist.extend([plist.pop(),plist.pop()])\n",
    "plist.insert(2,plist.pop(3))\n",
    "new_phrase = \"\".join(plist)\n",
    "print(plist)\n",
    "print(new_phrase)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9f010bbe",
   "metadata": {},
   "source": [
    "## P72"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7374a1b1",
   "metadata": {},
   "source": [
    "### 赋值操作符"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "0290c8c1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3, 4, 5, 6]"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "first = [1,2,3,4,5]\n",
    "first\n",
    "second = first\n",
    "second.append(6)\n",
    "second"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "2897c86b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3, 4, 5, 6]"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "first"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "434d736a",
   "metadata": {},
   "source": [
    "### copy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "00441db5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3, 4, 5, 6]"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "first = [1,2,3,4,5]\n",
    "second = first.copy()\n",
    "second.append(6)\n",
    "second"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "093bd3f8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3, 4, 5]"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "first"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "40656f8e",
   "metadata": {},
   "source": [
    "## p82"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "bdb7c26e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Don't panic!\n",
      "['D', 'o', 'n', \"'\", 't', ' ', 'p', 'a', 'n', 'i', 'c', '!']\n",
      "['D', 'o', 'n', \"'\", 't', ' ', 'p', 'a', 'n', 'i', 'c', '!']\n",
      "on tap\n"
     ]
    }
   ],
   "source": [
    "phrase = \"Don't panic!\"\n",
    "plist = list(phrase)\n",
    "print(phrase)\n",
    "print(plist)\n",
    "new_phrase = ''.join(plist[1:3])\n",
    "new_phrase = new_phrase + \"\".join([plist[5],plist[4],plist[7],plist[6]])\n",
    "print(plist)\n",
    "print(new_phrase)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "36245943",
   "metadata": {},
   "source": [
    "## p88"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "6bc25a85",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\t m\n",
      "\t a\n",
      "\t r\n",
      "\t v\n",
      "\t i\n",
      "\t n\n"
     ]
    }
   ],
   "source": [
    "paranoid_android = \"marvin\"\n",
    "letters = list(paranoid_android)\n",
    "for char in letters:\n",
    "    print('\\t',char)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c483e262",
   "metadata": {},
   "source": [
    "## p89"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "71f6a38e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\t m\n",
      "\t a\n",
      "\t r\n",
      "\t v\n",
      "\t i\n",
      "\t n\n",
      "\n",
      "\t\t a\n",
      "\t\t n\n",
      "\t\t d\n",
      "\t\t r\n",
      "\t\t o\n",
      "\t\t i\n",
      "\t\t d\n",
      "\n",
      "\t\t\t a\n",
      "\t\t\t r\n",
      "\t\t\t a\n",
      "\t\t\t n\n",
      "\t\t\t o\n",
      "\t\t\t i\n",
      "\t\t\t d\n",
      "\t\t\t  \n"
     ]
    }
   ],
   "source": [
    "paranoid_android = \"marvin,the paranoid android\"\n",
    "letters = list(paranoid_android)\n",
    "for char in letters[0:6]:\n",
    "    print('\\t',char)\n",
    "print()\n",
    "for char in letters[-7:]:\n",
    "    print('\\t'*2,char)\n",
    "print()\n",
    "for char in letters[12:20]:\n",
    "    print('\\t'*3,char)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "497d88b4",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
